package is.client.controller;

import is.client.model.ClientModel;
import is.client.ui.Gui;
import is.common.interfaces.mvc.Controller;

import java.io.IOException;

/**
 * @author aspr0
 */
public class ClientController implements Controller
{
    private Gui userInterface;
    private ClientModel model;

    public ClientController()
    {
        this.userInterface = new Gui();
        this.model = new ClientModel();
    }

    public void activate(String... params)
    {
        /* GUI will activate ClientModel on connect attempt */
        userInterface.activate();
    }

    public void deactivate(String... params)
    {
        try
        {
            model.deactivate();
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        userInterface.deactivate();
        System.exit(0);
    }

    @Override
    public Gui getUserInterface()
    {
        return userInterface;
    }

    @Override
    public ClientModel getModel()
    {
        return model;
    }
}
